package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Rscentre;
import com.ruoyi.system.service.IRscentreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 登记服务中心Controller
 * 
 * @author ruoyi
 * @date 2023-05-21
 */
@RestController
@RequestMapping("/recentre/rscentre")
public class RscentreController extends BaseController
{
    @Autowired
    private IRscentreService rscentreService;

    /**
     * 查询登记服务中心列表
     */
    @PreAuthorize("@ss.hasPermi('recentre:rscentre:list')")
    @GetMapping("/list")
    public TableDataInfo list(Rscentre rscentre)
    {
        startPage();
        List<Rscentre> list = rscentreService.selectRscentreList(rscentre);
        return getDataTable(list);
    }

    /**
     * 导出登记服务中心列表
     */
    @PreAuthorize("@ss.hasPermi('recentre:rscentre:export')")
    @Log(title = "登记服务中心", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Rscentre rscentre)
    {
        List<Rscentre> list = rscentreService.selectRscentreList(rscentre);
        ExcelUtil<Rscentre> util = new ExcelUtil<Rscentre>(Rscentre.class);
        util.exportExcel(response, list, "登记服务中心数据");
    }

    /**
     * 获取登记服务中心详细信息
     */
    @PreAuthorize("@ss.hasPermi('recentre:rscentre:query')")
    @GetMapping(value = "/{rsId}")
    public AjaxResult getInfo(@PathVariable("rsId") Long rsId)
    {
        return success(rscentreService.selectRscentreByRsId(rsId));
    }

    /**
     * 新增登记服务中心
     */
    @PreAuthorize("@ss.hasPermi('recentre:rscentre:add')")
    @Log(title = "登记服务中心", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Rscentre rscentre)
    {

        return toAjax(rscentreService.insertRscentre(rscentre));
    }

    /**
     * 修改登记服务中心
     */
    @PreAuthorize("@ss.hasPermi('recentre:rscentre:edit')")
    @Log(title = "登记服务中心", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Rscentre rscentre)
    {
        return toAjax(rscentreService.updateRscentre(rscentre));
    }

    /**
     * 删除登记服务中心
     */
    @PreAuthorize("@ss.hasPermi('recentre:rscentre:remove')")
    @Log(title = "登记服务中心", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rsIds}")
    public AjaxResult remove(@PathVariable Long[] rsIds)
    {
        return toAjax(rscentreService.deleteRscentreByRsIds(rsIds));
    }
}
